<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ include file="/include/taglibs.jsp"%>
<head>
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/huaxia.common.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/JHashMap.js"></script>
<style type="text/css">
body {
	/*background-image: url(../images/mainframe-bg.jpg);*/
	background-repeat: repeat-x;
	margin: 0px auto;
	padding: 0px;
	position: relative;
	text-align: center;
}
</style>

<script type="text/javascript">
function doSeleDelete(){  
	var prompt = "确实要删除选择设备吗？";	
	if(window.confirm(prompt)){
		var url_str = "<%=request.getContextPath()%>/ne.robotmanagenavi.do?method=delete&rnd"+Math.random();
		alert(url_str);
	//		frmList.action = url_str;		
	//		frmList.submit();	
	}
}

function doSeleAdd(){  
		var url_str = "<%=request.getContextPath()%>/ne.robotmanagenavi.do?method=add&rnd"+Math.random();
		frmList.action = url_str;		
		frmList.submit();	
}

function search(){			
   t_groupmanage.submit();	
}

</script>

<script type="text/javascript" >
function fnFam(str){
	return str.replace(/(^\,*)|(\,*$)/g, "");
}
var linkMap=new JHashMap();

function initMap(){
	var linkIds=document.getElementsByName("robotIds")[0].value;
	if(linkIds !=""){
		var linkIdsArr=linkIds.split(",");
		for(var i=0;i<linkIdsArr.length;i++){
			linkMap.put(linkIdsArr[i],linkIdsArr[i]);
		}
	}	
}

function selectLink(){
	initMap();	
	var var_rolegroupId=document.getElementById("queryIdRoleGroup").value;
	
	if(null==var_rolegroupId||""==var_rolegroupId){
		alert("请选择需要配置设备的权限组！");		
		return ;
	}
	
	openWindow('<c:url value="ne.rolerobotchoosequery.do?queryIdRoleGroup='+var_rolegroupId + '"/>',800,400,'yes');
}

function deleteLink(obj){
	initMap();
	var navigate_ids = document.getElementsByName("id");
	for(var i = 0;i < navigate_ids.length;i++){
		if(navigate_ids[i].checked){
			linkMap.remove(navigate_ids[i].value);
		}
	}
	var keyArr=linkMap.keySet();
	var keys="";
	if(keyArr!=null){
		for(var i=0;i<keyArr.length;i++){
			keys=keyArr[i]+","+keys;	
		}
		keys=fnFam(keys);
	}
    document.getElementById("robotIds").value=keys;
    obj.action="LspPingTaskNaviAction.do?navigate_action=add";;
    
    obj.submit();
}

 //定义重复提交标志变量
 var repeatSubmitFlag = false;
 //重复提交检查函数
 function form_submit(f,act,v){
    if(!v || v.validate()){
        var oaction = document.getElementById("navigate_action");
        oaction.value = act;
        <!-- 如果标志为true，则说明页面已经提交 -->
        if(repeatSubmitFlag) 
	    {
	       window.alert('禁止重复提交！');	      
	    }
	    else
	    {
	       repeatSubmitFlag = true;	 
	       f.submit();      
	    }
 	}
 }
 
//授权浏览
function selectGrantBrowse(){
var prompt = "确实要授权选择设备的浏览权限吗？";	
	if(window.confirm(prompt)){
		var url_str = "<%=request.getContextPath()%>/common.rolegroupnavi.do?action=grantBrowse";
		frmList.action = url_str;		
		frmList.submit();	
	}
}

//授权操作
function selectGrantExecute(){  
	var prompt = "确实要授权选择设备的操作权限吗？";	
	if(window.confirm(prompt)){
		var url_str = "<%=request.getContextPath()%>/common.rolegroupnavi.do?action=grantExecute";
		frmList.action = url_str;		
		frmList.submit();	
	}
}

//授权操作
function onChangeSelect(pRoleGroupId){  
	var v_idrolegroup=document.getElementById("idRoleGroup");	
	v_idrolegroup.value=pRoleGroupId;
}
</script>

<script type="text/javascript">
<!--
function senfe(o,a,b,c,d){
var t=document.getElementById(o).getElementsByTagName("tr");
for(var i=0;i<t.length;i++){
t[i].style.backgroundColor=(t[i].sectionRowIndex%2==0)?a:b;
t[i].onclick=function(){
if(this.x!="1"){
this.x="1";//本来打算直接用背景色判断，FF获取到的背景是RGB值，不好判断
this.style.backgroundColor=d;
}else{
this.x="0";
this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
}
}
$(t[i]).mouseover(function(){
if(this.x!="1")this.style.backgroundColor=c;
});
$(t[i]).mouseout(function(){
if(this.x!="1")this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
});
}
}
$(document).ready(function (){
	//senfe("表格名称","奇数行背景","偶数行背景","鼠标经过背景","点击后背景");
	senfe("T_RoleGroup","#e5f1f4","#f8fbfc","#ecfbd4","#bce774");
});
-->
</script>

</head>

<div>
<div style="text-align: left; color: red"><html:errors /></div>

<form id="frmList" action="ne.roleselrobotquery.do" method="post">
<table width="100%" border="0" cellpadding="3" cellspacing="0"
	class="sanxuan" style="background-repeat: repeat;">
	<tbody>
		<tr>
			<td height="31" width="900px"
				style="font-size: 14px; color: white; text-align: center">&nbsp;权限组查询</td>
		</tr>
		<tr>
			<td>
			<table border="0" width="95%" align="center">
				<tr align="left">
					<td><strong>权限组名:</strong><select id="queryIdRoleGroup"
						name="queryIdRoleGroup" style="width: 125px;">
						<option value="">请选择...</option>
						<c:forEach var="vo" items="${roleGroupList}">
							<option value="${vo.id}">${vo.roleGroupName}</option>
						</c:forEach>
					</select></td>
					<td align="left"><img
						src="<%=request.getContextPath() %>/images/table/chaxun.gif"
						width="90" height="30" style="cursor: hand;"
						onclick="javascript:search();" /></td>
				</tr>
			</table>
			</td>
		</tr>
	</tbody>
</table>
<div class="guanli" style="float: right;"><br />
<input name="add" type="button" class="button" value="添加设备"
	onclick="javascript:selectLink();" /><input name="add" type="button" class="button" value="授权浏览"
	onclick="javascript:selectGrantBrowse();" /><input name="add" type="button" class="button" value="授权操作"
	onclick="javascript:selectGrantExecute();" /></div>
	
<input type="hidden" id="idRoleGroup" name="idRoleGroup" value="${queryIdRoleGroup}">
<input type="hidden" id="robotIds" name="robotIds" >

<table width="100%" cellpadding="4" class="liebiao" id="T_RoleGroup"
	align="center">
	<thead>
		<tr>
			<td width="23" align="center"><input id="all" name="all"
				type="checkbox" onclick="list_select_all();" /></td>
			<td>权限组名</td>
			<td>所属区域</td>			
			<td>设备名称</td>
			<td>IP地址</td>
			<td>授权</td>			
			<td>操作</td>
		</tr>
	</thead>
	<tbody>
		<c:forEach var='bean' items="${RA_PAGER_ITEMS}" varStatus="vs">
			<tr>
				<td class="list-value"><input id="id" name="id" type="checkbox"
					value="${bean.robotManage.idRobot}"
					onClick="list_check_selection()"></td>				
				<td class="list-value">${bean.roleGroup.roleGroupName}</td>
				<td class="list-value">
					${bean.robotManage.regionManage.regionName}</td>
				<td class="list-value">${bean.robotManage.name}</td>
				<td class="list-value">${bean.robotNetInfo.ipAddress}</td>
				<td class="list-value">				     
				<c:if test="${bean.roleGroupRobot.roleLevel==1}">
					浏览
				</c:if>
				<c:if test="${bean.roleGroupRobot.roleLevel==2}">
					操作
				</c:if>
				</td>				
				<td class="list-value" style="width: 250px;"><a class="modify"
					href="common.rolegroupnavi.do?action=deleteRelRobot&id=${bean.robotManage.idRobot}&roleGroupId=${bean.roleGroup.id}">删除</a>
				</td>
			</tr>
		</c:forEach>
	</tbody>
	<tfoot>
	</tfoot>
</table>
<br />
<c:if test="{!empty RA_PAGER_ITEMS }">
<div class="pagenav"><jsp:include page="/include/pager.jsp"
	flush="true" /></div>
</c:if>
</form>
</div>
<script type="text/javascript">
var st = new SortableTable( document.getElementById("T_RoleGroup"), ["None", "String","String", "String","String","String","None" ,"None"],'#E4EEF7','white','#FF9900');
selectOption('queryIdRoleGroup','${queryIdRoleGroup}');
initMap();
</script>